/*
 * Copyright (c) 2014 Strong Group - 版权所有
 * 
 * This software is the confidential and proprietary information of
 * Strong Group. You shall not disclose such confidential information 
 * and shall use it only in accordance with the terms of the license 
 * agreement you entered into with www.cnstrong.cn.
 */
package com.zuorenke.redis;

import redis.clients.jedis.JedisPubSub;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 *
 * 描述:通用缓存客户端接口
 *
 * @author  WQB
 * @created 2014-5-20 下午4:24:05
 * @since   v1.0.0
 */
public interface CacheClient {

	void flushAll();
	
	Long ttl(String key);
	
	Set<String> keys(String pattern);
	
	Long expire(String key, int seconds);
	
	Boolean exists(String key);

	Boolean set(String key, Object value);

	Boolean set(String key, int seconds, Object value);

	Boolean set(String key, String value, String nxxx, long time);

    Boolean eval(String script, List<String> keys, List<String> args);

	List<Object> batchSet(List<String> keys, List<Object> values);

	Object get(String key);

	byte[] getBytes(String key);

	List<Object> batchGet(String[] keys);
	
	<T> Object get(String key, Class<T> t);

	Boolean delete(String key);

	Object batchDelete(String[] keys);

	Long lpush(String key, Object value);

	List<Object> lrange(String key, int start, int end);

	Long llen(String key);

	Object rpop(String key);

	Object lpop(String key);

	Long decrBy(String key, long integer);

	Long incr(String key);
	
	Long incrBy(String key, long integer);

	Long hset(String key, String field, Object value);
	
	<T> String hmset(String key, Map<String, T> map);

	Object hget(String key, String field);

    byte[] hgetBytes(String key, String field);

    Long hincrBy(String key, String field, long integer);

	List<Object> hmget(String key, String... fields);
	
	List<String> hmgetStr(String key, String... fields);

	Boolean hexists(String key, String field);

	Set<String> hkeys(String key);

	Map<String, Object> hgetAll(String key);

	Long hdel(String key, String field);

	void publish(String channel, String message);

	void psubscribe(JedisPubSub jedisPubSub, String[] patterns);

    Long sadd(String key, List<Object> values);

    Long sadd(String key, Object value);

    <T> Set<T> smembers(String key);

    Boolean sismember(String key, Object value);

    Long srem(String key, List<Object> values);

    Long srem(String key, Object value);

    Long scard(String key);

    Long zadd(String key, double score, Object member);

    Long zadd(String key, Map<Object, Double> scoreMembers);

    Long zrem(String key, Object value);

    <T> List<T> zrange(String key, long start, long end, boolean reverse);

    <T> Map<T, Double> zrangeWithScores(String key, long start, long end);

    <T> List<T> zrangeByScore(String key, double min, double max);

    <T> Map<T, Double> zrangeByScoreWithScores(String key, double min, double max);

    Long zcard(String key);

    Double zscore(String key, Object member);

    Long zcount(String key, double min, double max);

    Long zrank(String key, Object member, boolean reverse);
}
